home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / cluster2.zip / SOURCE.ZIP / PB3BOXES.BU < prev    next >
Text File  |  1996-06-16  |  30KB  |  811 lines

  1. '╒═══════════════════════════════════════════════════════════════════════════╕
  2. '│                                                                           │
  3. '│  Text Screen routines for PowerBASIC                                      │
  4. '│  Copyright (c) 1995 by PowerBASIC, Inc.  All Rights Reserved.             │
  5. '│                                                                           │
  6. '│  Note:  These routines are written for maximum speed and will have to be  │
  7. '│         modified to prevent snow on older CGA cards.                      │
  8. '│                                                                           │
  9. '├───────────────────────────────────────────────────────────────────────────┤
  10. '│                                                                           │
  11. '│  LineEdit    -  Edit a line of text; can be longer than the edit window   │
  12. '│  LineInput   -  Get a line of text from the user with a specified limit   │
  13. '│  PgCopy      -  Copy one Text video page to another on a color screen     │
  14. '│  QATTR       -  Change the background attributes of a given location      │
  15. '│  QBOX        -  Display a text box with in a specified color              │
  16. '│  QFILL       -  Fill a specified location with a char and attribute       │
  17. '│  QPRINT      -  Quickly print a string to the screen                      │
  18. '│  QPRINTC     -  Quickly print a centered string to the screen             │
  19. '│  QREST       -  Restore a saved portion of the screen                     │
  20. '│  QSAVE       -  Save a portion of the screen                              │
  21. '│  ScrollDown  -  Scroll a specified portion of the screen down             │
  22. '│  ScrollUp    -  Scroll a specified portion of the screen up               │
  23. '│  SetBlink    -  Change the blink bit status on EGA/VGA text screens       │
  24. '│                                                                           │
  25. '├───────────────────────────────────────────────────────────────────────────┤
  26. '│                                                                           │
  27. '│ 10 June 96 --  Bud Durland                                                │
  28. '│                                                                           │
  29. '│  Modified to store saved screen areas in dynamic strings;  minor bug      │
  30. '│  in QATTR corrected; input routine changed for more control.              │
  31. '│                                                                           │
  32. '│   The original routines in SCRNUNIT were written to save screen           │
  33. '│   areas inINTEGER arrays.  This is OK if you are only doing one box at    │
  34. '│   a time, but is expensive in terms of memory for multiple boxes.         │
  35. '│   Using strings to save screen areas is more economical, since you can    │
  36. '│   create a string array for however many boxes you will be using, and     │
  37. '│   dynamic strings will then only consume enough memory to hold the        │
  38. '│   screen area specified.  An integer array would always have to be        │
  39. '│   dimensioned for the largest possible screen area.                       │
  40. '│                                                                           │
  41. '╘═══════════════════════════════════════════════════════════════════════════╛
  42.  
  43.  
  44. $COMPILE UNIT ".\SCRNUNIT.PBU"
  45. $CODE SEG "SCRNLIB"
  46. $CPU      8086      ' Make compatible with XT systems
  47. $LIB      ALL OFF   ' Turn off all PowerBASIC libraries
  48. $ERROR    ALL OFF   ' Turn off all PowerBASIC error checking
  49. $OPTIMIZE SIZE      ' Optimize for smaller code
  50.  
  51. DEFINT    A-Z       ' Required for all numeric functions, forces PB to not
  52.                     ' include floating point in UNIT (makes it smaller)
  53.  
  54. DECLARE SUB GetStrLoc()     ' internal string locator in RTL
  55.  
  56.  
  57. $INCLUDE ".\PB3BOXES.HDR"      ' includes defs & declares for all modules.
  58.  
  59.  
  60. '===========================================================================
  61. ' QSAVE - saves specified portion of a text screen in a string
  62. '
  63. ' Row   = Starting screen row of area to save
  64. ' Col   = Starting screen column of area to save
  65. ' Rows  = Number of rows to save (must be 1 or greater)
  66. ' Cols  = Number of columns to save (must be 1 or greater)
  67. ' Where = string where data is to be saved
  68. '
  69. SUB QSAVE(BYVAL Row  AS INTEGER, BYVAL Col  AS INTEGER, _
  70.           BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER, _
  71.           Where AS STRING) LOCAL PUBLIC
  72.  
  73.   DIM ScrnSeg AS INTEGER
  74.   DIM WhereMem AS DWORD
  75.  
  76.   IF (pbvScrnCard AND 1) = 0 THEN
  77.     ScrnSeg = &HB800        ' color monitor
  78.   ELSE
  79.     ScrnSeg = &HB000        ' mono monitor
  80.   END IF
  81.  
  82.   dLen% = (Rows * Cols) * 2                     ' how much data to store?
  83.   Where = LEFT$(Where + SPACE$(dLen%),dLen%)    ' make string long enough
  84.   WhereMem = STRPTR32(Where)
  85.  
  86.   ! push DS                 ; save DS for PowerBASIC
  87.  
  88.   ! les  DI, WhereMem       ; put location of array element in ES:DI
  89.   ! mov  AX, ScrnSeg        ; put screen segment in AX
  90.   ! mov  DS, AX             ; move to DS
  91.  
  92.   ! mov  AX, Row            ; put row in AX
  93.   ! dec  AX                 ; minus one
  94.   ! mov  CX, 160            ; AX =
  95.   ! mul  CX                 ;   AX * 160
  96.   ! mov  SI, AX             ; put it in SI
  97.   ! mov  AX, Col            ; put column in AX
  98.   ! dec  AX                 ; minus one
  99.   ! shl  AX, 1              ; times 2
  100.   ! add  SI, AX             ; add to SI
  101.   ! mov  DX, Rows           ; put rows in DX
  102. SaveRow:
  103.   ! mov  CX, Cols           ; put number of columns in CX
  104.   ! push SI                 ; save screen offset
  105.   ! rep  movsw              ; copy CX words to array from screen
  106.   ! pop  SI                 ; restore screen offset
  107.   ! add  SI, 160            ; move to next row
  108.   ! dec  DX                 ; one less row to do
  109.   ! jnz  SaveRow            ; if it's zero, we're done
  110.  
  111.   ! pop  DS                 ; restore DS for PowerBASIC
  112.  
  113. END SUB
  114.  
  115.  
  116. '===========================================================================
  117. ' QREST - Restores specified portion of a text screen from a string
  118. '
  119. ' Row   = Starting screen row of area to restore
  120. ' Col   = Starting screen column of area to restore
  121. ' Rows  = Number of rows to restore (must be 1 or greater)
  122. ' Cols  = Number of columns to restore (must be 1 or greater)
  123. ' Where = Starting element of integer array where data is to be restored from
  124. '
  125. SUB QREST(BYVAL Row  AS INTEGER, BYVAL Col  AS INTEGER, _
  126.           BYVAL Rows AS INTEGER, BYVAL Cols AS INTEGER, _
  127.           Where AS STRING) LOCAL PUBLIC
  128.  
  129.   DIM ScrnSeg AS INTEGER
  130.   DIM WhereMem AS DWORD
  131.  
  132.   IF (pbvScrnCard AND 1) = 0 THEN
  133.     ScrnSeg = &HB800        ' color monitor
  134.   ELSE
  135.     ScrnSeg = &HB000        ' mono monitor
  136.   END IF
  137.  
  138.   WhereMem = STRPTR32(Where)  ' point to data in string
  139.  
  140.   ! push DS                 ; save DS for PowerBASIC
  141.  
  142.   ! lds  SI, WhereMem       ; put location of array in DS:SI
  143.   ! mov  AX, ScrnSeg        ; put screen segment in AX
  144.   ! mov  ES, AX             ; move to ES
  145.  
  146.   ! mov  AX, Row            ; put row in AX
  147.   ! dec  AX                 ; minus one
  148.   ! mov  CX, 160            ; AX =
  149.   ! mul  CX                 ;   AX * 160
  150.   ! mov  DI, AX             ; put it in DI
  151.   ! mov  AX, Col            ; put column in AX
  152.   ! dec  AX                 ; minus one
  153.   ! shl  AX, 1              ; times 2
  154.   ! add  DI, AX             ; add to DI
  155.   ! mov  DX, Rows           ; put rows in DX
  156. RestoreRow:
  157.   ! mov  CX, Cols           ; put number of columns in CX
  158.   ! push DI                 ; save screen offset
  159.   ! rep  movsw              ; copy CX words to array from screen
  160.   ! pop  DI                 ; restore screen offset
  161.   ! add  DI, 160            ; move to next row
  162.   ! dec  DX                 ; one less row to do
  163.   ! jnz  RestoreRow         ; if it's zero, we're done
  164.  
  165.   ! pop  DS                 ; restore DS for PowerBASIC
  166.  
  167. END SUB
  168.  
  169.  
  170. '===========================================================================
  171. ' QBOX - Display a box on the screen
  172. '
  173. ' Row  = Starting screen row of box
  174. ' Col  = Starting screen column of box
  175. ' Rows = Number of rows for the box
  176. ' Cols = Number of columns for the box
  177. ' Attr = Color